<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
{#提交地址#}
<form action="/add_data" method="post">
{#设置隐藏字段csrf_tokon 只要使用CSRFProject，然后使用模板渲染的时候直接使用csrf_token()方法 #}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
作者：<input type="text" name="author"><br>
书籍：<input type="text" name="book"><br>
    <input type="submit" value="添加"><br>

    {%  for mess in get_flashed_messages() %}
        <span style="color: red">{{ mess }}</span>
    {% endfor %}
</form>
<hr>
    <ul>
        {% for author in authors %}
{#            <li>作者: {{ author.name }}  <a href="/delete_author/{{ author.id }}">删除</a></li><br>#}
            <li>作者: {{ author.name }}  <a href="{{ url_for("delete_author",author_id = author.id)}}">删除</a></li><br>
            <ul>
                {% for book in author.books %}
                    <li>书籍: {{ book.name }} <a href="/delete_book/{{ book.id }}">删除</a></li><br>
                {% endfor %}
            </ul>
        {% endfor %}
    </ul>
</body>
</html>